package com.example.demo.controller;

import com.example.demo.commen.AppResult;
import com.example.demo.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "测试api接口")
@RestController
@RequestMapping("/test")
public class TestController {

    @ApiOperation("这是Expection异常的测试01")
  @RequestMapping(method = RequestMethod.GET,value = "01")
    public AppResult testException() throws Exception {
        throw  new Exception("这是Expection异常");
    }

 @RequestMapping("02")
 @ApiOperation("这是applicationException异常的测试02")
    public AppResult applicationException(){
        throw new ApplicationException("这是applicationException异常");
    }


    @ApiOperation("这是测试03请求方法")
    @RequestMapping("03")
    public AppResult fun(@ApiParam("这是对传入参数的测试") String name){
        return AppResult.success("hello:"+name);
    }

}
